import 'package:baselib/utils/color_base_util.dart';
import 'package:baselib/utils/image_util.dart';
import 'package:baselib/utils/px_base_util.dart';
import 'package:baselib/utils/string_base_util.dart';
import 'package:baselib/widgets/gradient_card_view.dart';
import 'package:baselib/widgets/inkwell_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:framelib/utils/color_util.dart';
import 'package:framelib/utils/drawable_util.dart';
import 'package:framelib/utils/px_util.dart';
import 'package:framelib/utils/string_util.dart';
import 'package:framelib/widgets/main_gradient_button.dart';
import 'package:framelib/widgets/page_widget.dart';
import 'package:get/get.dart';

import 'comm_widget_manager.dart';

class ChatRoomPersonInfoWidget extends StatelessWidget {
  String coverPath;
  String name;
  int userId;
  String positiveText;
  String cancelText;
  Function onFollow;
  Function onPositivePressEvent;
  Function onMorePressed;
   ChatRoomPersonInfoWidget({Key key,
     this.coverPath,this.name,this.userId,
     this.onFollow,
     this.positiveText,
     this.cancelText,
     this.onPositivePressEvent,
     this.onMorePressed,
   }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        GradientCardView(
            margin: EdgeInsets.only(top: PxUtil.instance.px_10),
            elevation: PxUtil.instance.px_0,
            borderRadius: BorderRadius.circular(PxUtil.instance.px_8),
            child: Container(
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  color: ColorUtil.instance.color_2F4072,
                  borderRadius:
                  BorderRadius.circular(PxUtil.instance.px_8),
                ),
                child: Container(
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Row(
                          mainAxisAlignment: MainAxisAlignment.end,
                          children: [
                            InkWellButton(
                              onPressed: (){
                                if(onMorePressed!=null)onMorePressed();
                              },
                              child: Container(
                                margin: EdgeInsets.all(PxUtil.instance.px_15),
                                child: ImagesUtil.loadAssetImage(
                                    DrawableUtil.instance.icon_chat_room_person_info_more,
                                    height: PxUtil.instance.px_6,
                                    fit: BoxFit.fitHeight
                                ),
                              ),
                            )
                          ],
                        ),
                        _buildPortraitContUi(),
                        SizedBox(height: PxUtil.instance.px_10,),
                        //名称、性别、等级
                        Container(
                          child: Text(
                            '${name??'${StringUtil.instance.unknow}'}',
                            style: TextStyle(
                                color: ColorUtil.instance.color_white,
                                fontSize: PxUtil.instance.px_13,
                                fontWeight: FontWeight.w500
                            ),
                          ),
                        ),
                        SizedBox(height: PxUtil.instance.px_10,),
                        //ID
                        Container(
                          child: Text(
                            '${StringUtil.instance.ID}：${userId??0}',
                            style: TextStyle(
                              color: ColorUtil.instance.color_cacaca,
                              fontSize: PxUtil.instance.px_10,
                            ),
                          ),
                        ),

                        SizedBox(
                          height: PxBaseUtil().px_35,
                        ),
                        Container(
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              GestureDetector(
                                onTap: () {
                                  if (onFollow != null) onFollow();
                                },
                                child: GradientCardView(
                                    elevation: PxBaseUtil().px_0,
                                    borderRadius: BorderRadius.circular(
                                        PxBaseUtil().px_18),
                                    child: Container(
                                      height: PxBaseUtil().px_35,
                                      decoration: BoxDecoration(
                                        borderRadius: BorderRadius.circular(
                                            PxBaseUtil().px_18),
                                        color:
                                        ColorBaseUtil().color_transparent,
                                      ),
                                      padding: EdgeInsets.only(
                                        left: PxUtil.instance.px_36,
                                        right: PxUtil.instance.px_36,
                                      ),
                                      child: Center(
                                        child: Text(
                                          cancelText??
                                              StringUtil.instance.Follow,
                                          style: TextStyle(
                                              color:
                                              ColorBaseUtil().color_white,
                                              fontSize: PxBaseUtil().px_14),
                                        ),
                                      ),
                                    )),
                              ),
                              SizedBox(
                                width: PxBaseUtil().px_30,
                              ),
                              GestureDetector(
                                onTap: () {
                                  if (onPositivePressEvent != null)
                                    onPositivePressEvent();
                                },
                                child: GradientCardView(
                                    elevation: PxBaseUtil().px_0,
                                    borderRadius: BorderRadius.circular(
                                        PxBaseUtil().px_18),
                                    child: Container(
                                      height: PxBaseUtil().px_35,
                                      decoration: BoxDecoration(
                                        borderRadius: BorderRadius.circular(
                                            PxBaseUtil().px_18),
                                        color: ColorBaseUtil().color_2F4072,
                                      ),
                                      padding: EdgeInsets.only(
                                        left: PxUtil.instance.px_36,
                                        right: PxUtil.instance.px_36,
                                      ),
                                      child: Center(
                                        child: Text(
                                          positiveText ??
                                              StringBaseUtil().Confirm,
                                          style: TextStyle(
                                              color: ColorBaseUtil()
                                                  .color_white,
                                              fontSize: PxBaseUtil().px_14),
                                        ),
                                      ),
                                    )),
                              ),
                            ],
                          ),
                        ),
                        SizedBox(
                          height: PxBaseUtil().px_30,
                        ),
                      ],
                    ),
                )
            )
        )
      ],
    );
  }

  _buildPortraitContUi() {
    return GradientCardView(
        elevation: PxBaseUtil().px_0,
        borderRadius: BorderRadius.circular(
            PxBaseUtil().px_40),
        child: Container(
            height: PxBaseUtil().px_80,
            width: PxBaseUtil().px_80,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(
                  PxBaseUtil().px_40),
              color:
              ColorBaseUtil().color_transparent,
            ),
            child:
            CommWidgetManager.buildCicleImagWidget(
              coverPath ?? '',
              placeholder: DrawableUtil.instance.icon_default_head,
              width: PxUtil.instance.px_80,
              height: PxUtil.instance.px_80,
              roundRadius: PxUtil.instance.px_40,
              backgroundColor: ColorUtil.instance.color_f2f2f2,
              padding: EdgeInsets.only(),
              margin: EdgeInsets.only(),
            )
        ));
  }
}
